// Copyright (c) 2025 Yao Yu
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use crate::cpu::SyscallArgs;
use ostd::cpu::context::UserContext;

// syscall args realize for x86_64
impl SyscallArgs for UserContext {
    fn syscall_num(&self) -> usize {
        self.rax()
    }
    fn syscall_ret(&self) -> usize {
        self.rax()
    }
    fn set_syscall_num(&mut self, num: usize) {
        self.set_rax(num)
    }
    fn set_syscall_ret(&mut self, ret: usize) {
        self.set_rax(ret)
    }
    fn syscall_args(&self) -> [usize; 6] {
        [
            self.rdi(), 
            self.rsi(), 
            self.rdx(), 
            self.r10(), 
            self.r8(), 
            self.r9(),
        ]
    }
}